package com.szrt.java.day20170113.demo01;

import java.math.BigDecimal;
import java.math.RoundingMode;

public class Student {

	private int card;
	
	private String name;
	
	private String phone;

	public Student() {
		System.out.println("反射或者框架底层调用的都是无参的构造方法！");
	}
	public Student(int card, String name, String phone) {
		this.card = card;
		this.name = name;
		this.phone = phone;
	}
	
	@SuppressWarnings("unused")
	private void diary(){
		System.out.println("打开别人的日记本...");
	}
	
	/**
	 * 1.23 + 3.456 = 4.686 = 4.69
	 * @param x
	 * @param y
	 * @return
	 */
	@SuppressWarnings("unused")
	private double add(double x,double y){
		BigDecimal xx = new BigDecimal(x);
		BigDecimal yy = new BigDecimal(y);
		
		//保留两位小数，四舍五入
		BigDecimal result = xx.add(yy).setScale(2, RoundingMode.HALF_UP);
		
		return result.doubleValue();
	}
	
	public int add(int x,int y){
		return x+y;
	}
	
	public int getCard() {
		return card;
	}
	public void setCard(int card) {
		this.card = card;
	}
	
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
	public String getPhone() {
		return phone;
	}
	public void setPhone(String phone) {
		this.phone = phone;
	}
	
	public void sing(){
		System.out.println("唱国歌...");
	}
	
	@SuppressWarnings("unused")
	private void findGirlfirend(){
		System.out.println("找女朋友..");
	}
	
	@Override
	public String toString() {
		return "Student [card=" + card + ", name=" + name + ", phone=" + phone + "]";
	}
	
	
	
}
